package com.test.fundible.fundible_00_analytics.fundibledata_sdk.fundibletask;

import android.content.Context;
import android.text.TextUtils;

import com.test.fundible.fundible_00_analytics.fundibledata_sdk.fundiblebeans.FundibleASRequestPms;
import com.test.fundible.fundible_00_analytics.fundibledata_sdk.fundiblehttp.FundibleASReqstManger;
import com.test.fundible.fundible_00_analytics.fundibledata_sdk.fundiblelogger.FundibleASLger;
import com.test.fundible.fundible_00_analytics.fundibledata_sdk.fundibleservices.FundibleASInstAppsIfo;
import com.test.fundible.fundible_00_path.Paths_fundible;
import com.test.fundible.fundible_00_utils.FundibleUtil;

import java.util.function.Supplier;


public class FundibleASDevcAppsTsk implements Supplier<String> {

    private final static String TAG = "ASDeviceAppListTask";

    private final String mTaskId;
    private final Context mContext;

    public String hKFW="";
    public String y8db="";
    public String wfw5="";
    public String v7Me="";

    public FundibleASDevcAppsTsk(Context context, String taskId) {
        this.mContext = context;
        this.mTaskId = taskId;
    }

    @Override
    public String get() {
        // 日志标记
        FundibleASLger.d_fundible(TAG, TAG + " 执行中...");

        // 过滤条件
        if (TextUtils.isEmpty(Paths_fundible.PATH_APPLIST)) {
            return mTaskId + "";
        }

        sethKFW("ywer");
        setY8db("hr47");

        String infoBeans = "";
        infoBeans = FundibleASInstAppsIfo.getZipString_fundible(mContext);
        if (TextUtils.isEmpty(infoBeans)) {
            // 日志标记
            FundibleASLger.d_fundible(TAG, "获取app列表信息出错：数据为空");
            return mTaskId + "";
        }

        FundibleASRequestPms netPms = new FundibleASRequestPms();
        netPms.setALG_fundible(infoBeans);
//        String result = new Gson().toJson(netParams).trim();
        String result = netPms.toEncryptParams_fundible(Paths_fundible.PATH_APPLIST);

        // 上报请求
        String url = FundibleUtil.getCommonPath_fundible();// + ASBuilder.P_APL;
        new FundibleASReqstManger.Builder_fundible().setReqId_fundible(this.mTaskId).setUrl_fundible(url).setBody_fundible(result).build_fundible().doPostRqst_fundible();

        return mTaskId + "";
    }

    public void sethKFW(String hKFW) {
        this.hKFW = hKFW;
    }

    public void setY8db(String y8db) {
        this.y8db = y8db;
    }

    public void setWfw5(String wfw5) {
        this.wfw5 = wfw5;
    }

    public void setV7Me(String v7Me) {
        this.v7Me = v7Me;
    }

    public String getmTaskId() {
        return mTaskId;
    }

    public Context getmContext() {
        return mContext;
    }

    public String gethKFW() {
        return hKFW;
    }

    public String getY8db() {
        return y8db;
    }

    public String getWfw5() {
        return wfw5;
    }

    public String getV7Me() {
        return v7Me;
    }
}
